<?php

namespace App\Admin\Renderable;

use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use App\Models\KaoqinLog;
use Illuminate\Support\Facades\DB;

class KaoQinDetails extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new KaoqinLog(), function (Grid $grid) {

//            $grid->perPages([10, 20, 30, 40, 50,100,200,300,400,500]);
//            var_dump($grid->model()->filter()->input('start'));
//->whereBetween('today_date',[$this->payload['start'],$this->payload['end']])
            $grid->model()->where('id_card', $this->payload['id_card']);

            $grid->column('today_date','打卡日期');

            $grid->column('morning','上午')->display(function ($morning) {
                if($morning == 1){
                    return "<span style='color:blue'>已打卡</span>";
                }else{
                    return "<span style='color:red'>未打卡</span>";
                }
            });
            $grid->column('afternoon','下午')->display(function ($afternoon) {
                if($afternoon == 1){
                    return "<span style='color:blue'>已打卡</span>";
                }else{
                    return "<span style='color:red'>未打卡</span>";
                }
            });

            $grid->column('morning_time','上午打卡时间');
            $grid->column('afternoon_time','下午打卡时间');



            $grid->disableActions();


        });
    }
}
